﻿@{
    ViewBag.Title = HttpUtility.HtmlDecode(Model.Title) + " - " + Model.Account.NickName;
    Layout = "~/Views/Shared/_BlogLayout.cshtml";
    var preAndnext = ViewBag.PrevAndNext as List<Tuple<int, string>>;
}
@using MyBlog
@model ArticleModel

<div class="dmain">
    <div class="dleft-article-main">
        <div style="background:#E8FDEB;">
            <div class="dleft_title">
                <a href="@Request.Url">@(Model.IsTop ? "[置顶]" + Model.Title : Model.Title)</a>
            </div>
            <div class="dleft_title_author">
                <span class="spuid"><i class="icon-user green"></i> @Model.Account.NickName</span>
                <span>发表于@(Model.CreateTime.ToString("yyyy-MM-dd HH:mm"))</span>
                <span>
                    <i class="icon-eye-open"></i> 浏览(<label class="red">@Model.ReadCount</label>)
                </span>
                <span onclick="gotoComment()">
                    <i class="icon-comments"></i> 评论(<label id="spcount1" class="red">@Model.ArticleCommentModels.Count</label>)
                </span>
                @if (ViewBag.CanEdit)
                {
                    <a class="edit" href="@Url.Action("release/" + Model.ID)">[编辑]</a>@:&nbsp;
                    <a class="edit" href="javascript:;" onclick="delArticle(@Model.ID)">[删除]</a>@:&nbsp;
                }
            </div>
            <div class="dleft-title-tags">
                <span><i class="icon-flag"></i> 分类：</span>
                @if (Model.CategoryModels.Count > 0)
                {
                    <span class="article-spcates">
                        @foreach (var c in Model.CategoryModels)
                        {
                            @:<a title="查看分类为[@(c.CategoryName)]的文章" href="@Url.Action("articles", new { cid = c.ID })">@c.CategoryName</a>&nbsp;
                    }
                    </span>
                }
                else
                {
                    <span>[未分类]</span>
                }
            </div>
            <div class="dleft-title-tags">
                <span><i class="icon-tags"></i> 标签：</span>
                @if (Model.TagModels.Count > 0)
                {
                    foreach (var item in Model.TagModels)
                    {
                        <a title="查看标签为[@(item.TagName)]的文章" href="@Url.Action("articles",new {tagID=item.ID })">@item.TagName</a>
                    }
                }
                else
                {
                    <span>暂无标签</span>
                }
            </div>
        </div>
        <div id="dcontent" class="dcontent ueditorContent">
            @Html.Raw(Model.Content)
        </div>
        <div class="bottom-op">
            <span title="不咋滴啊~" onclick="cai()" class="article-agree"><i class="icon-thumbs-down"></i> 踩(0)</span>
            <span title="除了赞还是赞~" onclick="agree(@Model.ID,@Model.AgreeCount,this)" class="article-agree"><i class="icon-heart"></i> 赞(@Model.AgreeCount)</span>
        </div>
        @if (preAndnext.Count > 0)
            {
            <div class="dv-article-pre-next">
                <ul>
                    @for (int i = 0; i < preAndnext.Count; i++)
                    {
                        if (preAndnext[i].Item1 > 0)
                        {
                            <li>@(i == 0 ? "上一篇" : "下一篇")：<a href="@Url.Action("article/"+preAndnext[i].Item1)">@preAndnext[i].Item2</a></li>
                        }
                        else
                        {
                            <li> @(i == 0 ? "上一篇" : "下一篇")：没有了</li>
                        }
                    }
                </ul>
            </div>
        }
    </div>
    <div id="dcomments" class="dcomments">
        <div class="commlist-tip"><i class="icon-comments"></i> 评论列表(<span id="spcount2">@Model.ArticleCommentModels.Where(x => x.Parent == null).Count()</span>)</div>
        <input type="hidden" id="hID" value="0" />
        <div id="dvCommentMain">
            @{Html.RenderAction("_CommentManager", new { aid = Model.ID });}
        </div>
        <div class="dv-sendcomm-tip">
            发表评论 <i class="icon-edit"></i>
        </div>
        <div id="dvSendComment" class="dv-send-comm">
            @if (Model.AllowComment)
            {
                if (UserSession.LoginUserInfo == null)
                {
                    Html.RenderAction("_logintip", "system");
                }
                else
                {
                    @:当前用户：<span class="sp-bold">@UserSession.LoginUserInfo.NickName</span>
                    <script id="content" name="content" class="input-content" type="text/plain">
                    </script>
                    <input type="button" id="btnok" value="提交" class="btnsubmit" style="margin-top:60px;" />
                }
            }
            else
            {
                <div id="_logintip" class="login-tip">系统提示：作者已关闭本文评论功能</div>
            }
        </div>
    </div>
</div>
<script src="~/Scripts/Blog/article.js"></script>
<script type="text/javascript">
    var articleID=@Model.ID;
</script>